package com.itheima.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@Aspect
//@Order(2)
public class MethodInfoAspect {


    @Around("@annotation(com.itheima.annotation.MyAnno)")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        //        1.获取目标对象类名
        String className = pjp.getTarget().getClass().getName();
        log.info("目标对象类名：{}",className);

        //        2.获取目标对象方法名
        String methodName = pjp.getSignature().getName();
        log.info("目标对象方法名：{}",methodName);

        //        3.获取目标对象参数值
        Object[] args = pjp.getArgs();
        log.info("目标对象参数值：{}",args);

        //        4.获取目标对象类名
        Object result = pjp.proceed();
        log.info("目标对象返回值：{}",result);

        return result;
    }
}
